<template>
  <div class="movie-list">
    <div class="title-filter-container">
      <div v-if="route.name === 'Movies'" class="hot-classify_btnList__2JGRN">
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">全部电影</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
          <div id="halo_div_dom" class="halo_button__9WYXP" style="visibility:hidden"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">免费</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">院线</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">2024</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">内地</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">中国香港</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">美国</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">动作</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">喜剧</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">动画</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">网络电影</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
        <div class="halo_divContainer__czfwR hot-classify_buttonTxt__D-jN5" style="cursor: pointer;">
          <div id="icon"></div>
          <span id="text">新片速递</span>
          <div id="cover"></div>
          <div id="gradientBorder"></div>
        </div>
      </div>
      <h2>{{ getCategoryTitle }}</h2>
    </div>
    <div class="movie-grid">
      <div v-for="movie in filteredMovies" :key="movie.id" class="movie-card">
        <img :src="movie.poster" :alt="movie.title" />
        <h3>{{ movie.title }}</h3>
        <p>{{ movie.description }}</p>
        <router-link :to="{ name: 'MovieDetail', params: { id: movie.id } }">查看详情</router-link>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const props = defineProps({
  category: {
    type: String,
    default: null
  }
})

const allMovies = ref([
  { id: 1, title: '奔跑吧兄弟 第十二季', poster: '../picture/电影/p1.jpg', description: '国民级户外竞技真人秀', category: 'variety' },
  { id: 2, title: '中国新说唱 2024', poster: '../picture/电影/p2.jpg', description: '华语说唱音乐选秀节目', category: 'variety' },
  { id: 3, title: '王牌对王牌 第八季', poster: '../picture/电影/p3.jpg', description: '室内竞技真人秀', category: 'variety' },
  { id: 4, title: '青春有你 第四季', poster: '../picture/电影/p4.jpg', description: '偶像养成类选秀节目', category: 'variety' },
  { id: 5, title: '哈哈哈哈哈 第三季', poster: '../picture/电影/p5.jpg', description: '公路行进式户外真人秀', category: 'variety' },
  { id: 6, title: '乘风破浪的姐姐 第四季', poster: '../picture/电影/p6.jpg', description: '30+女性艺人成团竞技节目', category: 'variety' },
  { id: 7, title: '极限挑战 第九季', poster: '../picture/电影/p7.jpg', description: '大型户外励志体验真人秀', category: 'variety' },
  { id: 8, title: '这！就是街舞 第六季', poster: '../picture/电影/p8.jpg', description: '街舞选拔类真人秀', category: 'variety' },
  { id: 9, title: '三体', poster: '../picture/电影/p1.jpg', description: '科幻题材电视剧', category: 'tv' },
  { id: 10, title: '庆余年第二季', poster: '../picture/电影/p2.jpg', description: '古装权谋剧', category: 'tv' },
  { id: 11, title: '流浪地球3', poster: '../picture/电影/p3.jpg', description: '科幻灾难电影', category: 'movies' },
  { id: 12, title: '满江红', poster: '../picture/电影/p4.jpg', description: '悬疑喜剧电影', category: 'movies' },
  { id: 13, title: '海贼王', poster: '../picture/电影/p5.jpg', description: '经典日本动漫', category: 'anime' },
  { id: 14, title: '斗罗大陆', poster: '../picture/电影/p6.jpg', description: '中国玄幻动漫', category: 'anime' },
  { id: 15, title: '地球脉动3', poster: '../picture/电影/p7.jpg', description: '自然纪录片', category: 'documentaries' },
  { id: 16, title: '人间世', poster: '../picture/电影/p8.jpg', description: '医疗健康纪录片', category: 'documentaries' }
])

const filteredMovies = computed(() => {
  if (!props.category || props.category === 'home') {
    return allMovies.value.slice(0, 8); // 首页显示热门内容
  }
  return allMovies.value.filter(movie => movie.category === props.category);
})

const getCategoryTitle = computed(() => {
  const categoryMap = {
    'tv': '电视剧',
    'movies': '电影',
    'variety': '综艺',
    'anime': '动漫',
    'documentaries': '纪录片'
  };
  return categoryMap[props.category] || '热门影视';
})
</script>

<style scoped>
.movie-list {
  padding: 20px;
  background-color: #1a1a1a; /* 加深背景色为较深的黑色 */
}

.title-filter-container {
  display: flex;
  flex-direction: column; /* 修改为垂直布局 */
  align-items: flex-start; /* 左对齐 */
  margin-bottom: 20px;
}

.movie-list h2 {
  color: white; /* 设置标题文字颜色为白色 */
  margin: 0;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.movie-card {
  border: none; /* 去除白色边缘边框 */
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  background-color: #2d2d2d; /* 加深卡片背景色 */
}

.movie-card img {
  width: 100%;
  height: auto;
  border-radius: 8px;
}
.movie-card h3 {
  color: white;
}
.movie-card p {
  color: white;
}

.hot-classify_btnList__2JGRN {
  margin: 20px 0;
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.halo_divContainer__czfwR {
  position: relative;
  padding: 8px 16px;
  border-radius: 20px;
  transition: all 0.3s ease;
}

.halo_divContainer__czfwR:hover {
  background-color: rgba(59, 130, 246, 0.1);
}

#icon {
  display: none;
}

#text {
  color: white;
  font-size: 14px;
}

#cover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.halo_divContainer__czfwR:hover #cover {
  opacity: 1;
}

#gradientBorder {
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border-radius: 22px;
  background: linear-gradient(45deg, #3b82f6, #2563eb);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.halo_divContainer__czfwR:hover #gradientBorder {
  opacity: 1;
}

.halo_button__9WYXP {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.2);
  filter: blur(10px);
  z-index: -2;
}
</style>